package com.qdlc.p2p.biz.processor.task;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qdlc.p2p.biz.processor.event.TppTradeLogValueEvent;
import com.qdlc.p2p.common.constant.SinaConstant;
import com.qdlc.p2p.common.constant.Summary;
import com.qdlc.p2p.common.constant.SummaryConstant;
import com.qdlc.p2p.common.constant.TradeCode;
import com.qdlc.p2p.common.core.queue.QueueHandlers;
import com.qdlc.p2p.dal.dto.TppTradeLog;

/**
 * 代收/代付异步通知处理：现金红包兑换
 * @author linya 2016-01-13
 */
@Service
@Transactional
public class CollectionTradeNotifyRedEnvelopeTaskProcessor extends AbstractCollectionTradeNotifyBaseTaskProcessor {

	/**
	 * 支持红包类型
	 * @param serviceType  服务类型
	 * @see SummaryConstant
	 * @return
	 */
	@Override
	public boolean supprotTradeFinished(String serviceType) {
		return Summary.CASH_RED_ENVELOPE_EXCHAGE.getSummaryType().equals(serviceType);
	}
	
	/**
	 * 代付交易类型
	 * @return
	 */
	public TradeCode tradeCode(){
		return TradeCode.C1001; 
	}
	
	/**
	 * 实现代付逻辑，发起代付请求
	 * @param tppTradeLog
	 */
	@Override
	protected void doPay(TppTradeLog tppTradeLog) {
		tppTradeLog.setTradeType(SinaConstant.TRADE_CODE_2001);
		TppTradeLogValueEvent event = new TppTradeLogValueEvent();
		event.setTppTradeLog(tppTradeLog);
//		event.setTaskProcessorClass(RedEnvelopePayTaskProcessor.class);
		QueueHandlers.put(event);
	}
	
}
